﻿<Page x:Class="Shell.Metro.MetroButtonPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"
	Title="MetroButtonPage">
    <Page.Resources>
        <Color x:Key="bgColor">#FF1570A6</Color>
        <Color x:Key="bgColorHL">#FF083047</Color>

        <SolidColorBrush x:Key="ButtonBackgroundBrush" Color="{StaticResource bgColor}"/>
        <SolidColorBrush x:Key="ButtonBackgroundBrushHL" Color="#FF009DEF"/>
        <SolidColorBrush x:Key="ButtonForegroundBrush" Color="#FFFFFFFF"/>

        <Style TargetType="{x:Type Button}">
            <!--<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>-->
            <Setter Property="Background" Value="{StaticResource ButtonBackgroundBrush}"/>
            <Setter Property="Foreground" Value="{StaticResource ButtonForegroundBrush}"/>
            <Setter Property="BorderBrush" Value="{StaticResource ButtonBackgroundBrush}"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="0,0,0,0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="ContentContainer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition From="MouseOver" GeneratedDuration="0" To="Normal">
                                            <Storyboard>
                                                <ColorAnimation Duration="0:0:0.4" To="{StaticResource bgColor}" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ContentContainer"/>
                                            </Storyboard>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ColorAnimation Duration="0:0:0.4" To="{StaticResource bgColorHL}" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ContentContainer"/>

                                            <!--<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ContentContainer">
                                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource bgColor}"/>
                                                <EasingColorKeyFrame KeyTime="0:0:0.3" Value="{StaticResource bgColorHL}"/>
                                                </ColorAnimationUsingKeyFrames>-->
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed"/>
                                    <VisualState x:Name="Disabled"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <!--<Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedFocused"/>-->
                            </Trigger>
                            <Trigger Property="IsDefaulted" Value="true">
                                <!--<Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedFocused"/>-->
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <!--<Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedPressed"/>-->
                            </Trigger>
                            <Trigger Property="ToggleButton.IsChecked" Value="true">
                                <!--<Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedPressed"/>-->
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Page.Resources>
    <!--<Grid Background="#FF1570A6">-->
    <Grid>
            <StackPanel VerticalAlignment="Center">
            <Button Width="150" Height="60" Margin="5,5,0,0">
                    <TextBlock Text="按钮一" HorizontalAlignment="Center" FontSize="20"/>
            </Button>
            <Button Width="150" Height="60" Margin="5,5,0,0">
                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                    <TextBlock Text="显示两行文本的按钮" HorizontalAlignment="Center"/>
                    <TextBlock Text="按钮二" HorizontalAlignment="Center" FontSize="20"/>
                </StackPanel>
            </Button>
        </StackPanel>
    </Grid>
</Page>
